﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            //int[,] arry = new int[2, 6] { { 0, 1, 2, 3, 4, 5 }, { 10, 11, 12, 13, 14, 15 } };
            DataClasses1DataContext DB = new DataClasses1DataContext();



            var parent = from proj in DB.GetTable<PROJECTCLASS>()
                         where proj.PC_PARENT == 0
                         select new { PC_CODE = proj.PC_CODE, PC_ID = proj.PC_ID, PC_NAME = proj.PC_NAME, PC_PARENT = proj.PC_PARENT };

            var sum = from proj in DB.GetTable<PROJECTCLASS>()
                      where proj.PC_PARENT != 0
                      select new { PC_CODE = proj.PC_CODE, PC_ID = proj.PC_ID, PC_NAME = proj.PC_NAME, PC_PARENT = proj.PC_PARENT };


            foreach (var item in parent)
            {
                Console.WriteLine(item.PC_CODE + "   " + item.PC_ID + "   " + item.PC_NAME + "   " + item.PC_PARENT);
            }
            Console.WriteLine("\n");
            foreach (var item in sum)
            {
                Console.WriteLine(item.PC_CODE + "   " + item.PC_ID + "   " + item.PC_NAME + "   " + item.PC_PARENT);
            }
            Console.WriteLine("\n");

            var parent_id_all = from p1 in DB.GetTable<PROJECTCLASS>()
                                join p3 in DB.GetTable<PROJECTCLASS>() on p1.PC_ID equals p3.PC_PARENT
                                select new
                                {
                                    PC_ID = p3.PC_ID,
                                    PC_CODE = p1.PC_CODE,
                                    PC_NAME = p1.PC_NAME,
                                    PC_PARENT = p1.PC_PARENT,
                                  
                                };


            Console.WriteLine("\n");
            foreach (var item in parent_id_all)
            {
                Console.WriteLine(item.PC_CODE + "   " + item.PC_ID + "   " + item.PC_NAME + "   " + item.PC_PARENT + "   " );
            }


            Console.WriteLine("\n...  " + parent_id_all.Count());




            Console.ReadKey(true);

        }


        static void BindCategoryTreeViews(int curr_id, int curr_parent_id, char chpad)
        {


        }

    }
}
